package com.recsmile.sgs.client.commonds.sync;

import com.recsmile.sgs.client.commonds.GeneralGameUIClientCommand;
import com.recsmile.sgs.client.entity.Hero;
import com.recsmile.sgs.client.ui.components.GamePanel;

public class SyncHealthLimitGameUIClientCommand extends GeneralGameUIClientCommand {
	
	private static final long serialVersionUID = -6642017853595462196L;

	private final String name;
	private final int limit;
	
	public SyncHealthLimitGameUIClientCommand(String name, int limit) {
		this.name = name;
		this.limit = limit;
	}

	@Override
	protected void execute(GamePanel<? extends Hero> panel) {
		if (panel.getContent().getSelf().getName().equals(name)) {
			panel.getContent().getSelf().changeHealthLimitTo(limit);
		} else {
			panel.getContent().getPlayer(name).changeHealthLimitTo(limit);
		}
	}

}